package jkws

import (
	cbase "findService/ss/servicebase"

	"golang.org/x/net/websocket"
)

type CMWSMsg struct {
	conn    *websocket.Conn
	// Who send here
	src     cbase.MsgPayload
	// Tell to mqtt
	payload cbase.MsgPayload
}

type CMWSMsgList struct {
	list []CMWSMsg
}

func newWSMsgList() *CMWSMsgList {
	l := &CMWSMsgList{}
	return l
}

func (m *CMWSMsgList) Add(msg *CMWSMsg) {
	m.list = append(m.list, *msg)
}

func (m *CMWSMsgList) Find(seq uint) *CMWSMsg {
	for _, v := range m.list {
		if v.payload.Seq == seq {
			return &v
		}
	}
	return nil
}
